package com.practices2.activity;

import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.widget.GridView;

import com.practices2.R;
import com.practices2.adapter.ImageAdapter;
import com.practices2.base.BaseActivity;
import com.practices2.base.TAApplication;

public class ImageListAcitvity extends BaseActivity {

	private GridView gv_photo;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_imagelist);
		initView();
	}

	private int getScreenWidth() {
		DisplayMetrics metrics = new DisplayMetrics();
		WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
		wm.getDefaultDisplay().getMetrics(metrics);
		return metrics.widthPixels;
	}

	private void initView() {
		gv_photo = (GridView) findViewById(R.id.gv_iamge);

		int imageSize = getScreenWidth() / 3;
		ImageAdapter adapter = new ImageAdapter(ImageListAcitvity.this, TAApplication.getApplication(), imageSize);
		gv_photo.setAdapter(adapter);
		setTitle(adapter.getCount() + "");

	}

}
